"""
@version:python3
@author:ll
@file:35-QFileDialog-功能作用.py
@time:2022/2/14 17:50
"""
from PyQt5.Qt import *

# global file_path
file_path = ""
class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("QFileDialog功能作用")
        self.resize(500, 500)
        self.setup_ui()

    def setup_ui(self):  # 添加子控件以及子控件的配置操作
        # result = QFileDialog.getOpenFileName(self,"选择一个py文件","./","ALL(*.*);;Images(*.png *.jpg);;python文件(*.py)","python文件(*.py)")
        # print(result[0])
        # print(result)


        def get_file(file):
            global file_path
            file_path = file
            print(file_path)
        def test_slot():
            fd = QFileDialog(self,"打开文件","./")
            fd.fileSelected.connect(get_file)
            fd.open()

        btn = QPushButton(self)
        btn.setText("测试按钮")
        btn.move(100, 100)
        btn.pressed.connect(test_slot)


if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    window = Window()
    window.show()

    sys.exit(app.exec_())
